package com.erp.framework.util.ftp;

import com.erp.framework.exceptions.SimpleException;

public class FTPException extends SimpleException {

    /**
     * Revision control id
     */
    private static String cvsId = "@(#)$Id: FTPException.java,v 1.1 2006/04/12 08:25:21 ric.yik Exp $";

    /**
     * Integer reply code
     */
    private int replyCode = -1;

    /**
     * Constructor. Delegates to super.
     * 
     * @param msg
     *            Message that the user will be able to retrieve
     */
    public FTPException(String msg) {
        super(msg);
    }

    /**
     * Constructor. Permits setting of reply code
     * 
     * @param msg
     *            message that the user will be able to retrieve
     * @param replyCode
     *            string form of reply code
     */
    public FTPException(String msg, String replyCode) {

        super(msg);

        // extract reply code if possible
        try {
            this.replyCode = Integer.parseInt(replyCode);
        } catch (NumberFormatException ex) {
            this.replyCode = -1;
        }
    }

    /**
     * Get the reply code if it exists
     * 
     * @return reply if it exists, -1 otherwise
     */
    public int getReplyCode() {
        return replyCode;
    }

}
